package view;
/*Palette.java
 *CS193J
 *Sumer2001
 */

import icons.DrawingIcon;
import icons.LineDrawingIcon;
import icons.MoveDrawingIcon;
import icons.OvalDrawingIcon;
import icons.RectangleDrawingIcon;
import icons.SelectionIcon;
import icons.SmilyDrawingIcon;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Panel;
import java.util.Enumeration;
import java.util.Vector;

/**A Palette is the visual entity (a Panel)
 * that contains all of the drawing
 * icons.  A Palette has a Vector of drawing icons. 
 *
 * @see DrawingIcon
 * @see Panel
 *
 * @author Jatinder Pal Singh
 */

public class Palette extends Panel {

  private Vector dDrawingIcons;
  private Dimension paletteDim;


  private Color dBorderColor = Color.black;

  /** this method creates all of the drawing icons that will be
      shown in the palette, and add them to the palette's vector of
      drawing icons. */

  private void createDrawingIcons () {
      /**creates the icons, inserts them into dDrawingIcons,
       * and adds them to the palette
       */
    dDrawingIcons = new Vector ();
    
    LineDrawingIcon lineIcon = new LineDrawingIcon();
    lineIcon.setSize(20,20);
    dDrawingIcons.add (lineIcon);
    add(lineIcon);
    
    
    RectangleDrawingIcon rectangleIcon = new RectangleDrawingIcon();
    dDrawingIcons.add (rectangleIcon);
    add (rectangleIcon);
    
    OvalDrawingIcon ovalIcon = new OvalDrawingIcon();
    dDrawingIcons.add (ovalIcon);
    add (ovalIcon);

    SmilyDrawingIcon smilyIcon = new SmilyDrawingIcon();
    dDrawingIcons.add (smilyIcon);
    add (smilyIcon);

    MoveDrawingIcon moveIcon = new MoveDrawingIcon();
    dDrawingIcons.add (moveIcon);
    add (moveIcon);

    SelectionIcon selectionIcon = new SelectionIcon();
    dDrawingIcons.add (selectionIcon);
    add (selectionIcon);
    
  }

  public void paint (Graphics g) {
    super.paint(g);
    g.setColor(dBorderColor);
    g.drawRect(0,0,getWidth()-1,getHeight()-1);
  }
    
  /** returns an enumeration of all of the drawing icons. */

  public Enumeration getAllDrawingIcons () {
      return dDrawingIcons.elements();
  }

  /** the constructor should call createDrawingIcons(), and
      add each of the drawing icons to this panel. */

  public Palette () {
    super (new GridLayout (1,6));
    paletteDim = new Dimension(480,50);
    createDrawingIcons ();
  }

  /** returns the preferred size of the palette. */
  public Dimension getPreferredSize () {
    return paletteDim;
  }

  /** returns the minimum size of the palette. */
  public Dimension getMinimumSize () {
    return paletteDim;
  }

  /** returns the maximum size of the palette. */
  public Dimension getMaximumSize () {
    return paletteDim;
  }
  
}
